package com.bigdatastudio.common.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Transient;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <h2>菜单权限</h2>
 *
 * @author 彭畅
 * @since 2022-10-12
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_menu")
public class Menu implements Serializable {

    /**
     * <h3>版本控制</h3>
     */
    private static final long serialVersionUID = 1L;

    /**
     * <h3>菜单编号</h3>
     */
    @TableId(value = "id", type = IdType.AUTO)
    @NotNull
    private Integer id;

    /**
     * <h3>菜单名称</h3>
     */
    private String menuName;

    /**
     * <h3>父菜单编号</h3>
     */
    private Integer parentId;

    /**
     * <h3>显示顺序</h3>
     */
    private Integer orderNum;

    /**
     * <h3>路由名称</h3>
     */
    private String name;

    /**
     * <h3>路由路径</h3>
     */
    private String path;

    /**
     * <h3>组件路径</h3>
     */
    private String component;

    /**
     * <h3>路由参数</h3>
     */
    private String query;

    /**
     * <h3>菜单图标</h3>
     */
    private String icon;

    /**
     * <h3>创建人</h3>
     */
    private String createName;

    /**
     * <h3>创建时间</h3>
     */
    @JsonFormat(pattern = "yyyy-MM-dd")  // 返回给前端的时候进行格式化
    private LocalDateTime createTime;

    /**
     * <h3>修改人</h3>
     */
    private String updateName;

    /**
     * <h3>修改时间</h3>
     */
    @JsonFormat(pattern = "yyyy-MM-dd")  // 返回给前端的时候进行格式化
    private LocalDateTime updateTime;

    /**
     * <h3>逻辑删除（1：已删除 0：未删除）</h3>
     */
    private Boolean isDelete;

    /**
     * <h3>备注</h3>
     */
    private String remark;

    @Transient
    @TableField(exist = false)
    private List<Menu> children;

}
